var vm = new Vue({
    el: '#mainindex',
    data: {
        fileType: 0,
        transLoglist: {},
        //图表数据
        chartsData: {
            legend: {},
            trans: {
                name: '',
                count: {}
            },
            job: {
                name: '',
                count: {}
            }
        },
        jobLogList: {},
        size: {
            count: 0,//总数
            transCount: 0,//任务
            jobCount: 0//作业
        }
    },
    methods: {
        //获取监控数
        getTaskCount: function () {
            $.getJSON(baseURL + "sys/menu/getTaskCount", function (r) {
                if (0 === r.code) {
                    vm.size = r.size;
                }

            });
        },
        transLog: function () {
            alert("就是测试下00")
        },
        jopLog: function () {
            alert("就是测试下11")
        },
        //获取转换记录Log
        getTransLog: function () {
            $.getJSON(baseURL + "sys/menu/getTransAndTaskLog/" + 0, function (r) {
                if (0 === r.code) {
                    vm.transLoglist = r.list;
                }

            });
        },
        //获取作业记录Log
        getJopLog: function () {
            $.getJSON(baseURL + "sys/menu/getTransAndTaskLog/" + 1, function (r) {
                if (0 === r.code) {
                    vm.jobLogList = r.list;
                }

            });
        },

        // 获取图表信息
        getKettleLine: function () {
            $.getJSON(baseURL + "sys/menu/getKettleLine", function (r) {
                if (0 === r.code && null != r.chartsData) {
                    vm.chartsData = r.chartsData;
                    var lineChart = echarts.init(document.getElementById("kettleLine"));
                    var lineoption = {
                        title: {
                            text: '7天内作业和转换的监控状况'
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        /*数据来源*/
                        legend: {
                            data: ['作业', '转换']
                        },
                        xAxis: [
                            {
                                data: vm.chartsData.legend
                            }
                        ],
                        yAxis: [
                            {
                                type: 'value',
                                axisLabel: {
                                    formatter: '{value}'
                                }
                            }
                        ],
                        //设置数值
                        series: [
                            {
                                name: vm.chartsData.trans.name,
                                type: 'line',
                                data: vm.chartsData.trans.count,
                                markPoint: {
                                    data: [
                                        {type: 'max', name: '最大值'},
                                        {type: 'min', name: '最小值'}
                                    ]
                                },
                            },
                            {
                                name: vm.chartsData.job.name,
                                type: 'line',
                                data: vm.chartsData.job.count,
                                markPoint: {
                                    data: [
                                        {type: 'max', name: '最大值'},
                                        {type: 'min', name: '最小值'}
                                    ]
                                },
                            }
                        ]
                    };
                    lineChart.setOption(lineoption);
                    $(window).resize(lineChart.resize);
                }
            });
        }
    },
    created: function () {
        this.getTaskCount();
        this.getTransLog();
        this.getJopLog();

    },
    mounted: function () {
        this.getKettleLine();
    }
});

